<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>资产信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
   <div class="Wrapper">
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <div class="btnsBox inLC">
                	<span id="cst_ass_info_car_add_btn_id" class="sq-button sq-button-round">添加</span>
                    <span id="cst_ass_info_car_modify_btn_id" class="sq-button sq-button-round">修改</span>
                    <span id="cst_ass_info_car_detail_btn_id" class="sq-button sq-button-round">详情</span>
                </div>
                <span>车辆资产信息</span>
            </div>
            <div class="sqPanel_body">
                <div id="ligergrid_cheliang" class="sq-grid"></div>
            </div>
        </div>
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <div class="btnsBox inLC">
                    <span id="cst_ass_info_Land_property_add_btn_id" class="sq-button sq-button-round">添加</span>
                    <span id="cst_ass_info_Land_property_modify_btn_id" class="sq-button sq-button-round">修改</span>
                    <span id="cst_ass_info_Land_property_detail_btn_id" class="sq-button sq-button-round">详情</span>
                </div>
                <span>土地/房产信息</span>
            </div>
            <div class="sqPanel_body">
                <div id="ligergrid_tudi" class="sq-grid"></div>
            </div>
        </div>
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <div class="btnsBox inLC">
                    <span id="cst_ass_info_other_add_btn_id" class="sq-button sq-button-round">添加</span>
                    <span id="cst_ass_info_other_modify_btn_id" class="sq-button sq-button-round">修改</span>
                    <span id="cst_ass_info_other_detail_btn_id" class="sq-button sq-button-round">详情</span>
                </div>
               <span>其他资产信息</span>
            </div>
            <div class="sqPanel_body">
                <div id="ligergrid_qitazichan" class="sq-grid"></div>
            </div>
        </div>
    </div>

   
    
    <!-- hide data -->
	<div class="fieldBox col_100" style="display:none;">
		<div class="field">
		    <input name=cstId id="cstId" type="text" class="ui-textbox" value="${cstId}">
		</div>
	</div>
    
    <script>
    $(function() {
        
    	//新增车辆资产信息
        $("#cst_ass_info_car_add_btn_id").click(function(event) {
            //如果客户ID不存在是不能新增的
        	var _cstId = $("#cstId").val();
        	if(!_cstId){
        		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO, SQ_type: "warning"});
                return; //验证不通过，不执行以下代码
        	}
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 750,
                height:410,
                title : '车辆资产信息',
                url:'<%=path%>/customer/cstassinfo/toCarAddPage.do?cstId='+_cstId
            });
        });
        
        //车辆资产信息修改
        $("#cst_ass_info_car_modify_btn_id").click(function(event) {
        	//如果客户ID不存在是不能修改
        	var _cstId = $("#cstId").val();
        	if(!_cstId){
        		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO, SQ_type: "warning"});
                return; //验证不通过，不执行以下代码
        	}
        	
        	var selectedRows = cstAssInfoCar.getSelectedRows();
    		if(selectedRows.length != 1){
    			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
    			return;
    		}
    		
    		var _id = selectedRows[0].id;
        	
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 750,
                height:410,
                title : '车辆资产信息',
                url:'<%=path%>/customer/cstassinfo/toCarAddPage.do?cstId='+_cstId+'&caiId='+_id
            });
        });
        
        //车辆资产信息详情
        $("#cst_ass_info_car_detail_btn_id").click(function(event) {
        	//如果客户ID不存在是不能查看
        	var selectedRows = cstAssInfoCar.getSelectedRows();
    		if(selectedRows.length != 1){
    			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
    			return;
    		}
    		
    		var _id = selectedRows[0].id;
        	
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 750,
                height:290,
                title : '车辆资产信息',
                url:'<%=path%>/customer/cstassinfo/toCarDetailPage.do?caiId='+_id
            });
        });
    	//新增土地房产资产信息
        $("#cst_ass_info_Land_property_add_btn_id").click(function(event) {
            //如果客户ID不存在是不能新增的
        	var _cstId = $("#cstId").val();
        	if(!_cstId){
        		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO, SQ_type: "warning"});
                return; //验证不通过，不执行以下代码
        	}
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 750,
                height:370,
                title : '土地房产资产信息',
                url:'<%=path%>/customer/cstassinfo/toLandPropertyAddPage.do?cstId='+_cstId
            });
        });
        
        //土地房产资产信息修改
        $("#cst_ass_info_Land_property_modify_btn_id").click(function(event) {
        	//如果客户ID不存在是不能修改
        	var _cstId = $("#cstId").val();
        	if(!_cstId){
        		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO, SQ_type: "warning"});
                return; //验证不通过，不执行以下代码
        	}
        	
        	var selectedRows = cstAssInfoLandProperty.getSelectedRows();
    		if(selectedRows.length != 1){
    			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
    			return;
    		}
    		
    		var _id = selectedRows[0].id;
        	
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 750,
                height:370,
                title : '土地房产资产信息',
                url:'<%=path%>/customer/cstassinfo/toLandPropertyAddPage.do?cstId='+_cstId+'&caiId='+_id
            });
        });
        
        //土地房产资产信息详情
        $("#cst_ass_info_Land_property_detail_btn_id").click(function(event) {
        	//如果客户ID不存在是不能查看
        	var selectedRows = cstAssInfoLandProperty.getSelectedRows();
    		if(selectedRows.length != 1){
    			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
    			return;
    		}
    		
    		var _id = selectedRows[0].id;
        	
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 750,
                height:290,
                title : '土地房产资产信息',
                url:'<%=path%>/customer/cstassinfo/toLandPropertyDetailPage.do?caiId='+_id
            });
        });
    	//新增其他资产信息
        $("#cst_ass_info_other_add_btn_id").click(function(event) {
            //如果客户ID不存在是不能新增的
        	var _cstId = $("#cstId").val();
        	if(!_cstId){
        		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO, SQ_type: "warning"});
                return; //验证不通过，不执行以下代码
        	}
        	
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 750,
                height:370,
                title : '其他资产信息',
                url:'<%=path%>/customer/cstassinfo/toOtherAddPage.do?cstId='+_cstId
            });
        });
        
        //其他资产信息修改
        $("#cst_ass_info_other_modify_btn_id").click(function(event) {
        	//如果客户ID不存在是不能修改
        	var _cstId = $("#cstId").val();
        	if(!_cstId){
        		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO, SQ_type: "warning"});
                return; //验证不通过，不执行以下代码
        	}
        	
        	var selectedRows = cstAssInfoOther.getSelectedRows();
    		if(selectedRows.length != 1){
    			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
    			return;
    		}
    		
    		var _id = selectedRows[0].id;
        	
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 750,
                height:370,
                title : '其他资产信息',
                url:'<%=path%>/customer/cstassinfo/toOtherAddPage.do?cstId='+_cstId+'&caiId='+_id
            });
        });
        
        //其他资产信息详情
        $("#cst_ass_info_other_detail_btn_id").click(function(event) {
        	//如果客户ID不存在是不能查看
        	var selectedRows = cstAssInfoOther.getSelectedRows();
    		if(selectedRows.length != 1){
    			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
    			return;
    		}
    		
    		var _id = selectedRows[0].id;
        	
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 600,
                height:250,
                title : '其他资产信息',
                url:'<%=path%>/customer/cstassinfo/toOtherDetailPage.do?caiId='+_id
            });
        });
    	
       
        $("#ligergrid_cheliang").ligerGrid({
            usePager: false,
            url: "<%=path%>/customer/cstassinfo/initCarList.do",
            method : 'get',
            columns: [{
                display: '设备名称',
                name: 'assNm',
                width: 150
            },{
                display: '品牌',
                name: 'brCd',
                width: 150
            }, {
                display: '型号',
                name: 'prdMdl',
                width: 150
            }, {
                display: '所有权人',
                name: 'assOwner',
                width: 150,
            }, {
                display: '市值(元)',
                name: 'value',
                width: 100
            }, {
                display: '数量',
                name: 'qty',
                width: 50
            }, {
                display: '收益(元)',
                name: 'revenue',
                minWidth: 100
            }, {
                display: '购买时间',
                name: 'purchDt',
                minWidth: 100,
                render:renderDate
            }, {
                display: '备注',
                name: 'assRem',
                minWidth: 200
            }, {
                display: '操作',
                isSort: false,
                width: 100,
                render: function (rowdata, rowindex, value){
                    var h='<a class="sq-button-hasicon" href="javascript:deleteCarRow(';
                        h+="'"+rowdata.id+"'";
                        h+=",'ligergrid_cheliang'"
                        h+=')"><i class="sqBtnIco_7"></i>删除</a>'
                    return h;
                }
            }],
            width: '100%',
            isScroll: false,
            rownumbers: true,
            root:'rows',
	        record:'total',
            onAfterShowData: function() {
                SetIframe_height();
            }
        });
        
        cstAssInfoCar = liger.get("ligergrid_cheliang");
        
        $("#ligergrid_tudi").ligerGrid({
            usePager: false,
            url: "<%=path%>/customer/cstassinfo/initLandPropertyList.do",
            method : 'get',
            columns: [{
                display: '所有人',
                name: 'assOwner',
                width: 150
            }, {
                display: '使用面积(㎡)',
                name: 'area',
                width: 150
            }, {
                display: '地址',
                name: 'addr',
                width: 150,
            }, {
                display: '估值',
                name: 'value',
                width: 150
            }, {
                display: '收益(元)',
                name: 'revenue',
                width: 150
            }, {
                display: '购买时间',
                name: 'purchDt',
                width: 150,
                render:renderDate
            }, {
                display: '备注',
                name: 'assRem',
                minWidth: 200
            }, {
                display: '操作',
                isSort: false,
                width: 100,
                render: function (rowdata, rowindex, value){
                    var h='<a class="sq-button-hasicon" href="javascript:deleteLandPropertyRow(';
                        h+="'"+rowdata.id+"'";
                        h+=",'ligergrid_tudi'"
                        h+=')"><i class="sqBtnIco_7"></i>删除</a>'
                    return h;
                }
            }],
            width: '100%',
            isScroll: false,
            rownumbers: true,
            root:'rows',
	        record:'total',
            onAfterShowData: function() {
                SetIframe_height();
                $(".liger_tip").ligerTip();
            }
        });
        
        cstAssInfoLandProperty = liger.get("ligergrid_tudi");
        
        $("#ligergrid_qitazichan").ligerGrid({
            usePager: false,
            url: "<%=path%>/customer/cstassinfo/initOtherList.do",
            method : 'get',
            columns: [{
                display: '所有人',
                name: 'assOwner',
                width: 120
            }, {
                display: '资产名称',
                name: 'assNm',
                width: 150
            }, {
                display: '估值',
                name: 'value',
                width: 150
            }, {
                display: '收益(元)',
                name: 'revenue',
                width: 150
            }, {
                display: '购买时间',
                name: 'purchDt',
                width: 150,
                render:renderDate
            }, {
                display: '备注',
                name: 'assRem',
                minWidth: 250
            }, {
                display: '操作',
                isSort: false,
                width: 100,
                render: function (rowdata, rowindex, value){
                    var h='<a class="sq-button-hasicon" href="javascript:deleteOtherRow(';
                        h+="'"+rowdata.id+"'";
                        h+=",'ligergrid_qitazichan'"
                        h+=')"><i class="sqBtnIco_7"></i>删除</a>'
                    return h;
                }
            }],
            width: '100%',
            isScroll: false,
            rownumbers: true,
            root:'rows',
	        record:'total',
            onAfterShowData: function() {
                SetIframe_height();
            }
        });
        
        cstAssInfoOther = liger.get("ligergrid_qitazichan");
        initData();
    })  
       
       
   
    
    //初始化数据
    function initData(){
    	initCstAssInfoCarData();//初始化车辆配置信息
    	initCstAssInfoLandPropertyData();//初始化土地房产信息
    	initCstAssInfoOtherData();//初始化其他资产信息
	}
    
  	//初始车辆资产信息
    function initCstAssInfoCarData(){
    	var cstId = $("#cstId").val();
    	cstAssInfoCar.setParm("cstId",cstId);
    	cstAssInfoCar.reload();
    }
  	//初始土地/房产资产信息
    function initCstAssInfoLandPropertyData(){
    	var cstId = $("#cstId").val();
    	cstAssInfoLandProperty.setParm("cstId",cstId);
    	cstAssInfoLandProperty.reload();
    }
  	//初始其他资产信息
    function initCstAssInfoOtherData(){
    	var cstId = $("#cstId").val();
    	cstAssInfoOther.setParm("cstId",cstId);
    	cstAssInfoOther.reload();
    }
  	
  	
    
    
  	//删除车辆资产信息
    function deleteCarRow (caiId, gridId) {
    	var cstId = $("#cstId").val();
    	if(!cstId){
    		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_ID_NOT_EMPTY, SQ_type: "warning"});
    		return;
    	}
    	$.ligerDialog.SQconfirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			
			var wait_dialog= $.ligerDialog.SQalert({
	            content: LogUtils.LOG_CMM_LOADING,
	            SQ_type: "waitting",
	            onClose: function () {
	            }
	        });
			
			$.ajax({
	     		type: 'post',
	     		dataType:'json',
	     		data:{id:caiId},
	     		url: '<%=path%>/customer/cstassinfo/removeCarById.do',
	     		success:function(msg){
	     			wait_dialog.close();
	     			 if(msg.success == 1){
	     				ligerDialogSuc(msg.info, 1000);
	     				cstAssInfoCar.setParm("cstId",cstId);
	     				cstAssInfoCar.reload();
	     			 }else{
	     				 $.ligerDialog.warn(msg.info);
	     			 }
	     		}
	     	});
		});
    }
  	
  //删除土地房产资产信息
    function deleteLandPropertyRow (caiId, gridId) {
    	var cstId = $("#cstId").val();
    	if(!cstId){
    		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_ID_NOT_EMPTY, SQ_type: "warning"});
    		return;
    	}
    	$.ligerDialog.SQconfirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			var wait_dialog= $.ligerDialog.SQalert({
	            content: LogUtils.LOG_CMM_LOADING,
	            SQ_type: "waitting",
	            onClose: function () {
	            }
	        });
			$.ajax({
	     		type: 'post',
	     		dataType:'json',
	     		data:{id:caiId},
	     		url: '<%=path%>/customer/cstassinfo/removeLandPropertyById.do',
	     		success:function(msg){
	     			wait_dialog.close();
	     			 if(msg.success == 1){
	     				$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
	     				cstAssInfoLandProperty.setParm("cstId",cstId);
	     				cstAssInfoLandProperty.reload();
	     			 }else{
	     				$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	     			 }
	     		}
	     	});
		});
    }
  //删除其他资产信息
    function deleteOtherRow (caiId, gridId) {
    	var cstId = $("#cstId").val();
    	if(!cstId){
    		$.ligerDialog.SQalert({content: LogUtils.LOG_CUST_ID_NOT_EMPTY, SQ_type: "warning"});
    		return;
    	}
    	$.ligerDialog.SQconfirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			var wait_dialog= $.ligerDialog.SQalert({
	            content: LogUtils.LOG_CMM_LOADING,
	            SQ_type: "waitting",
	            onClose: function () {
	            }
	        });
			$.ajax({
	     		type: 'post',
	     		dataType:'json',
	     		data:{id:caiId},
	     		url: '<%=path%>/customer/cstassinfo/removeOtherById.do',
	     		success:function(msg){
	     			wait_dialog.close();
	     			 if(msg.success == 1){
	     				$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
	     				cstAssInfoOther.setParm("cstId",cstId);
	     				cstAssInfoOther.reload();
	     			 }else{
	     				$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	     			 }
	     		}
	     	});
		});
    }
  //格式化时间
  function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}

    </script>
</body>
</html>